#include <stdio.h>
#include <string.h>

int main()
{
    /*
    int a[9][9] = {0};
    int n;
    scanf("%d", &n);
    int finalN = n * n;
    int i = 0, j = 0, number = 1;
    int new_n = n;
    int cnt = 0;
    while (cnt != finalN)
    {
        for (;j < new_n; j++, number++)
        {
            cnt++;
            a[i][j] = number;
        }
        j--;
        for (i++; i < new_n; i++, number++)
        {
            cnt++;
            a[i][j] = number;
        }
        i--;
        for (j--; j > n - new_n - 1; j--,number++)
        {
            cnt++;
            a[i][j] = number;
        }
        j++;
        for (i--; i > n - new_n; i--, number++)
        {
            cnt++;
            a[i][j] = number;
        }
        i++;
        new_n--;
        j++;
    }
    for (int k1 = 0; k1 < n; k1++)
    {
        for (int k2 = 0; k2 < n; k2++)
        {
            printf("%3d", a[k1][k2]);
        }
        if (k1 < n - 1)printf("\n");
    }
    */
   int n;
   scanf("%d", &n);
   int a[9][9] = {0};
   int k = 1;
   int bound0 = n - 1, bound1 = n - 1, bound2 = 0, bound3 = 1;
   int direction = 0;
   int i = 0, j = 0;
   while (k <= n * n)
   {
       if (direction == 0)
       {
           a[i][j++] = k++;
           if (j == bound0 + 1)
           {
                direction = 1;
                j--;
                i++;
                bound0--;
           }
       }
       else if (direction == 1)
       {
           a[i++][j] = k++;
           if (i == bound1 + 1)
           {
               direction = 2;
               i--;
               j--;
               bound1--;
           }
       }
       else if (direction == 2)
       {
           a[i][j--] = k++;
           if (j == bound2 - 1)
           {
               direction = 3;
               j++;
               i--;
               bound2++;
           }
       }
       else if (direction == 3)
       {
           a[i--][j] = k++;
           if (i == bound3 - 1)
           {
               direction = 0;
               i++;
               j++;
               bound3++;
           }
       }
   }
   for (int k1 = 0; k1 < n; k1++)
   {
       for (int k2 = 0; k2 < n; k2++)
       {
           printf("%3d", a[k1][k2]);
       }
       if (k1 < n - 1)
       {
           printf("\n");
       }
   }

    return 0;
}